package com.aliothservice.catfish.cart.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class Cart {

	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();

		map.put("id", this.getId());
		map.put("serviceObject", this.getServiceObject());
		if (null != this.getProductId()) {
			map.put("productId", this.getProductId());
			map.put("volume", this.getVolume());
		}
		if (null != this.getWarehouseId()) {
			map.put("warehouseId", this.getWarehouseId());
			DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			map.put("startDate", formatter.format(this.getStartDate()));
			map.put("untilDate", formatter.format(this.getUntilDate()));
			map.put("volume", this.getVolume());
		}
		if (null != this.getVehicleId()) {
			map.put("vehicleId", this.getVehicleId());
			DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			map.put("loadingDate", formatter.format(this.getLoadingDate()));
			map.put("temperatureSpec", this.getTemperatureSpec());
		}

		return map;
	}

	@Id
	private String id;

	private String userId;

	private String productId;
	private String warehouseId;
	private String vehicleId;

	private Date startDate;
	private Date untilDate;
	private Integer volume;
	private String temperatureSpec;
	private Date loadingDate;

	private Map<String, Object> serviceObject;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public String getWarehouseId() {
		return warehouseId;
	}

	public void setWarehouseId(String warehouseId) {
		this.warehouseId = warehouseId;
	}

	public String getVehicleId() {
		return vehicleId;
	}

	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getUntilDate() {
		return untilDate;
	}

	public void setUntilDate(Date untilDate) {
		this.untilDate = untilDate;
	}

	public Integer getVolume() {
		return volume;
	}

	public void setVolume(Integer volume) {
		this.volume = volume;
	}

	public Map<String, Object> getServiceObject() {
		return serviceObject;
	}

	public void setServiceObject(Map<String, Object> serviceObject) {
		this.serviceObject = serviceObject;
	}

	public String getTemperatureSpec() {
		return temperatureSpec;
	}

	public void setTemperatureSpec(String temperatureSpec) {
		this.temperatureSpec = temperatureSpec;
	}

	public Date getLoadingDate() {
		return loadingDate;
	}

	public void setLoadingDate(Date loadingDate) {
		this.loadingDate = loadingDate;
	}

}
